package group2assignone.ucm;

import group2assignone.model.Person;
import group2assignone.view.MainView;
import group2assignone.view.OurView;

/**
 * Use Case: Log Out<br>
 * Precondition: user is logged into an account<br>
 * Postcondition: main UI is shown<br>
 * 1. System logs out the user<br>
 * 2. System creates the new Main view<br>
 * 3. System starts the new Main view<br>
 * 4. System exists the current view<br>
 * @author group2
 */
public class UCLogout implements UCController {

    private OurView view;
    private Person p;

    public UCLogout(OurView view, Person p) {
        this.view = view;
        this.p = p;
    }

    /**
     * Use Case to logout any user that is logged in
     */
    public void run() {
        //1. System logs out the user
        p.logout();
        //2. System creates the new Main view
        MainView gui = new MainView();
        //3. System starts the new Main view
        gui.go();
        //4. System exists the current view
        view.dispose();
    }
}
